<?php

namespace App\Http\Requests;

use App\Http\Requests\Request;

class ResetPasswordRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'oldpassword' => 'required|alpha_dash',
            'newpassword' => 'required|alpha_dash|between:6,16',
            'repassword'  => 'required|alpha_dash|same:newpassword|between:6,16',
        ];
    }

    public function attributes()
    {
        $attributes = array(
            'oldpassword' => '原密码',
            'newpassword' => '新密码',
            'repassword'  => '重复新密码',
        );

        return $attributes;
    }

    public function messages()
    {
        $messages = [
            'required'       => ':attribute为必填选项',
            'numeric'        => ':attribute必须为数字',
            'alpha_dash'     => ':attribute只能包含字母和数字，以及破折号和下划线',
            'digits_between' => ':attribute长度必须介于6和16之间',
            'same'           => ':attribute和:other必须相同',
        ];

        return $messages;
    }
}
